<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">

	<ui:define name="content">
		<f:event type="preRenderView"
			listener="#{interviewController.beforeAdd}" />
		<div class="title ui-widget-header ui-corner-all">
			<h:panelGrid style="margin:auto;">
		AGREGAR ENTREVISTA
		</h:panelGrid>

		</div>
		<h:form id="formAdd">
			<h:panelGrid style="margin:auto;">

				<h:panelGrid style="margin:auto;text-align:center;">
					<p:messages id="messages"></p:messages>
				</h:panelGrid>

				<h:panelGrid columns="2" id="panelAdd">

					<h:panelGrid>


						<h:panelGrid columns="4">

							<p:outputLabel value="Documento de identidad"></p:outputLabel>

							<p:inputText id="candidateDocumentNumber"
								value="#{interviewController.candidateDocumentNumberSearch}"></p:inputText>
							<p:commandButton
								actionListener="#{interviewController.searchCandidateByDocumentNumber}"
								value="Buscar" process="@this :formAdd:candidateDocumentNumber"
								update=":formAdd:candidatesTable :formAdd:candidateId :formAdd:messages">
							</p:commandButton>

							<p:outputLabel id="candidateId"
								value="Candidato seleccionado: #{interviewController.candidateSelected!=null?interviewController.candidateSelected.id:''}">
							</p:outputLabel>

						</h:panelGrid>

						<p:dataTable value="#{interviewController.candidates}" var="c"
							rowKey="#{c.id}" id="candidatesTable" selectionMode="single"
							selection="#{interviewController.candidateSelected}" paginator="true" rows="5">

							<p:ajax event="rowSelect" update=":formAdd:candidateId" />
							<p:ajax event="rowUnselect" update=":formAdd:candidateId" />

							<p:column headerText="ID">
								<h:outputText value="#{c.id}"></h:outputText>
							</p:column>

							<p:column headerText="N° de Documento" sortBy="#{c.documentNumber}">
								<h:outputText value="#{c.documentNumber}"></h:outputText>
							</p:column>

							<p:column headerText="Nombres">
								<h:outputText value="#{c.firstname}"></h:outputText>
							</p:column>

							<p:column headerText="Apellidos">
								<h:outputText value="#{c.lastname}"></h:outputText>
							</p:column>
							
							<p:column headerText="Area">
								<h:outputText value="#{c.area.area.name}"></h:outputText>
							</p:column>

							<p:column headerText="Subarea">
								<h:outputText value="#{c.area.name}"></h:outputText>
							</p:column>
							
							<p:column headerText="Estado">
								<h:outputText value="#{c.candidateState.name}"/>
							</p:column>


						</p:dataTable>


					</h:panelGrid>
					<h:panelGrid columns="2">

						<p:outputLabel value="Fecha de Entrevista"></p:outputLabel>
						<p:calendar
							value="#{interviewController.interviewSelected.interviewedAt}"
							pattern="dd-MM-yyyy hh:mm:ss a" stepMinute="10" required="true"
							requiredMessage="Debe seleccionar fecha de entrevista">
						</p:calendar>

						<p:outputLabel value="Reclutador"></p:outputLabel>
						<p:selectOneMenu id="recruitments" required="true"
							requiredMessage="Debe seleccionar reclutador"
							value="#{interviewController.recruiterSelected}">
							<f:selectItem itemValue="" itemLabel="Seleccione.."></f:selectItem>
							<f:selectItems value="#{interviewController.recruiters}"></f:selectItems>
						</p:selectOneMenu>

						<p:outputLabel value="Comentarios:"></p:outputLabel>
						<p:inputTextarea
							value="#{interviewController.interviewSelected.comment}" rows="4"
							cols="30"></p:inputTextarea>

					</h:panelGrid>

				</h:panelGrid>

				<h:panelGrid style="margin:auto;text-align:center;">
					<p:commandButton action="#{interviewController.add}"
						value="Agregar" ajax="false">
					</p:commandButton>
				</h:panelGrid>
			</h:panelGrid>
		</h:form>
	</ui:define>

</ui:composition>
</html>
